<div class="da-list-wrap">
  <div class="da-content-banner">
    <d-breadcrumb>
      <d-breadcrumb-item><a routerLink="/">{{ 'product.breadcrumb.home' | translate }}</a></d-breadcrumb-item>
      <d-breadcrumb-item><a routerLink="/pages/product/product-job-pink">生产发料</a></d-breadcrumb-item>
      <d-breadcrumb-item>{{ 'product.breadcrumb.addProductJobPink' | translate }}</d-breadcrumb-item>
    </d-breadcrumb>
  </div>
  <div class="da-content-wrapper">
    <div class="da-form-container ">
      <div class="card">
        <div class="card-title">
          <p class="form-title">新增生产发料单</p>
        </div>
        <form dForm ngForm [layout]="layoutDirection" [labelSize]="'sm'" [labelAlign]="'end'"
          (dSubmit)="submit($event)">
          <div class="form-body">
            <div class="grid mt-3">
              <div class="u-1-2 ">
                <d-form-item>
                  <d-form-label>
                    <span class="label"><span class="Required">*</span>领料单号</span>
                  </d-form-label>
                  <d-form-control>
                    <input dTextInput class="form-input-box" name="领料单号" [(ngModel)]="jobOrderlssue.jobOrderIssueNum">
                  </d-form-control>
                </d-form-item>
              </div>
              <div class="u-1-2">
                <d-form-item>
                  <d-form-label>
                    <span class="label"><span class="Required">*</span>创建人</span>
                  </d-form-label>
                  <d-form-control>
                    <input dTextInput class="form-input-box" name="创建人" placeholder="请选择人员"
                      [(ngModel)]="jobOrderlssue.issueUserName" disabled>
                  </d-form-control>
                </d-form-item>
              </div>
              <div class="u-1-2">
                <d-form-item>
                  <d-form-label>
                    <span class="label"><span class="Required">*</span>发料方式</span>
                  </d-form-label>
                  <d-form-control>
                    <d-button (btnClick)="issuances()"><span>批量发料</span></d-button>
                    <d-button style="margin-left: 5px;" (btnClick)="selectPart()"><span>单独发料</span></d-button>
                  </d-form-control>
                </d-form-item>
              </div>
            </div>
            <div>
              <h4>发料汇总表</h4>
            </div>
            <div class="table">
              <d-data-table [dataSource]="this.jobOrderlssue.items" [lazy]="true" [scrollable]="true" [fixHeader]="true"
                [tableOverflowType]="'auto'" [scrollable]="true" [resizeable]="true"
                [tableWidthConfig]="tableWidthConfig">
                <thead dTableHead>
                  <tr dTableRow>
                    <th dHeadCell>
                      <span>操作</span>
                    </th>
                    <th dHeadCell *ngFor="let colOption of dataTableOptions.columns" [title]="colOption.header">
                      {{colOption.header}}</th>
                  </tr>
                </thead>
                <tbody dTableBody>
                  <ng-template let-rowItem="rowItem" let-rowIndex="rowIndex">
                    <tr dTableRow>
                      <td dTableCell>
                        <a class="devui-link-danger me-2" (click)="delete(rowIndex)">删除</a>
                        <a class="devui-link" (click)="apart(rowIndex)">拆分</a>
                      </td>
                      <td dTableCell dTooltip [content]="rowItem.jobOrderNum">{{rowItem.jobOrderNum}}</td>
                      <td dTableCell dTooltip [content]="rowItem.processName">{{rowItem.processName}}</td>
                      <td dTableCell dTooltip [content]="rowItem.partName">{{rowItem.partName}}</td>
                      <td dTableCell dTooltip [content]="rowItem.partNum">{{rowItem.partNum}}</td>
                      <td dTableCell dTooltip [content]="rowItem.unit">{{rowItem.unit}}</td>
                      <td dTableCell dTooltip [content]="rowItem.requirementQuantity">{{rowItem.requirementQuantity}}
                      </td>
                      <td dTableCell dTooltip [content]="rowItem.issuedQuantity">{{rowItem.issuedQuantity}}</td>
                      <td dTableCell>
                        <div style="display: flex; justify-content: center;">
                          <input style="width: 80%;" type="number" class="devui-form-control"
                            [(ngModel)]="rowItem.PreIssuedQuantity" [ngModelOptions]="{standalone: true}"
                            (change)="changeQuantity($event, rowIndex)" [max]="rowItem.partPositionInventory"
                            [min]="1" />
                        </div>
                      </td>
                      <td dTableCell>
                        <div style="display: flex; justify-content: center;">
                          <input style="width: 80%;" class="devui-form-control" [(ngModel)]="rowItem.warehouseName"
                            [ngModelOptions]="{standalone: true}" readonly (click)="SelectStorehouse(rowItem)"
                            placeholder="选择仓库" />
                        </div>
                      </td>
                      <td dTableCell>
                        <div style="display: flex; justify-content: center;">
                          <input style="width: 80%;" class="devui-form-control" [(ngModel)]="rowItem.positionName"
                            [ngModelOptions]="{standalone: true}" (click)="SelectStorehouse(rowItem)" readonly
                            placeholder="选择仓位" />
                        </div>
                      </td>
                      <td dTableCell dTooltip [content]="rowItem.stockQuantity ?? 0">{{rowItem.stockQuantity ?? 0}}</td>
                    </tr>
                  </ng-template>
                </tbody>
              </d-data-table>
            </div>
          </div>
          <d-form-operation>
            <d-button bsStyle="primary" dFormSubmit>确定</d-button>
            <d-button class="ms-3" bsStyle="common" (btnClick)="cancle()">取消</d-button>
          </d-form-operation>
        </form>
      </div>
    </div>
  </div>
</div>
<d-toast [value]="msgs" [life]="2000" [styleClass]="'custom-class'" [style]="{ left: '50%',top:'10px' }"></d-toast>
